package cn.bdqn.util;

import cn.bdqn.entity.Air;

import java.util.List;

public class PageBean {

    //1. 分页的信息
    /** 当前页 */
    private Integer currentPage;    //已知条件.
    /** 每页显示条数 */
    private Integer pageSize;       //已知条件.
    /** 总条数 */
    private Integer totalCount;     //查询出来的数据.
    /** 总页数 */
    private Integer totalPage;
    // totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1;
    //      (totalCount + pageSize - 1) / pageSize

    /** 起始索引 */
    private Integer startIndex;
    //  (currentPage - 1) * pageSize
    // 当前页            显示条数             limit
    //   1 - 1            10                    0
    //   2                10                   10
    //   3                10                   20

    //2. 全部的空气质量信息
    private List<Air> list;

    public PageBean(
            Integer currentPage,
            Integer pageSize,
            Integer totalCount) {
        //给已知条件复制
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
        //计算出totalPage和startIndex
        this.totalPage = totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1;
        this.startIndex = (currentPage - 1) * pageSize;
    }

    public Integer getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(Integer currentPage) {
        this.currentPage = currentPage;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(Integer totalCount) {
        this.totalCount = totalCount;
    }

    public Integer getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public Integer getStartIndex() {
        return startIndex;
    }

    public void setStartIndex(Integer startIndex) {
        this.startIndex = startIndex;
    }

    public List<Air> getList() {
        return list;
    }

    public void setList(List<Air> list) {
        this.list = list;
    }
}
